// message.js
import Vue from "vue";
import message from "./index.vue";

let messageConstructor = Vue.extend(message);
let instance;

const Message = (options = {}) => {
  instance = new messageConstructor({ data: options }).$mount(); // 渲染组件
  document.body.appendChild(instance.$el); // 挂载到 body 下
};

["success", "error", "info","danger"].forEach((type) => {
  Message[type] = (options) => {
    options.type = type;
    return Message(options);
  };
});

export default Message;
